package mya.mes.mdc.logic.alarm.filter;


import mya.mes.mdc.logic.tag.PlcTagCache;
import mya.mes.mdc.share.plc.PlcTagVoFilter;
import mya.mes.mdc.share.vo.plc.MdcAlarmTypeArray;
import mya.mes.mdc.share.vo.plc.PlcTagVo;

import java.util.ArrayList;
import java.util.List;

public class AlarmFilter implements PlcTagVoFilter {

    @Override
    public List<PlcTagVo> filter(List<PlcTagVo> voList) {
        if (voList == null) {
            return null;
        }
        List<PlcTagVo> alarmList = new ArrayList<>(voList.size());
        for (PlcTagVo vo : voList) {
            MdcAlarmTypeArray mdcAlarmTypeArray = PlcTagCache.getInstance().getMdcAlarmType(vo);
            if (mdcAlarmTypeArray == null) {
                continue;
            }
            vo.mdcAlarmTypeArray = mdcAlarmTypeArray;
            if (alarmList == null) {
                alarmList = new ArrayList<>();
            }
            alarmList.add(vo);
        }
        return alarmList;
    }
}
